<template>
  <div class="app-container">
    <el-row>
      <el-button type="primary" @click="createBanner" round>生成最新课程banner</el-button>
    </el-row>



      <h3>当前banner</h3>
      <el-carousel :interval="5000" arrow="always" style="margin-top: 30px;" height="600px">
        <el-carousel-item v-for="item in bannerList" :key="item.id" style="height: 600px;">
          <h3><img :src="item.imageUrl" style="width: 100%"></h3>
        </el-carousel-item>
      </el-carousel>





  </div>
</template>

<script>
  import banner from '@/api/banner'

    export default {
        name: "index",
      data(){
          return{
            bannerList:[],//轮播集合
          }
      },
      created(){
        this.getList()
      },
      methods:{
          createBanner(){
            banner.createBanner()
              .then(response=>{//调用接口成功后执行
                this.$message({
                  message: '生成成功',
                  type: 'success'
                });
                this.getList()
              })

          },
        //获取显示banner
        getList(){
            banner.getBanner()
              .then(resposne=>{
                this.bannerList = resposne.data.list
              })
        }
      }
    }
</script>

<style scoped>
  .el-carousel__item h3 {
    color: #475669;
    font-size: 18px;
    opacity: 0.75;
    line-height: 300px;
    margin: 0;
  }

  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }

  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
</style>
